﻿using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Security.Policy;
using DG.Common.EF.Reflection;
using DG.Common.Patterns.MVVM;

namespace TCC.ControleFluxoDeCaixa.Model.Entities
{
    public class FluxoContextFactory : NotifyViewModel
    {
        private static FluxoContextFactory _singletonInsance;
        private bool _showSqlLogInConsole;

        public event FluxoDeCaixaContext.SaveChangesExecutedHandler SaveChangesExecuted;
      
        public bool ShowSqlLogInConsole
        {
            get { return _showSqlLogInConsole; }
            set
            {
                if (value.Equals(_showSqlLogInConsole)) return;
                _showSqlLogInConsole = value;
                OnPropertyChanged("ShowSqlLogInConsole");
            }
        }

        public FluxoDeCaixaContextFiltrado Create()
        {
            var ctx = new FluxoDeCaixaContext();
            ctx.SaveChangesExecuted += (sender, time) =>
            {
                if (SaveChangesExecuted != null) SaveChangesExecuted(sender, time);
            };

            return new FluxoDeCaixaContextFiltrado(ctx); ;
        }

        private FluxoContextFactory()
        {
            ShowSqlLogInConsole = false;
        }

        public static FluxoContextFactory GetInstance()
        {
            return _singletonInsance ?? (_singletonInsance = new FluxoContextFactory());
        }

       


    }
}